home *** CD-ROM | disk | FTP | other *** search
- #include <string.h>
- #include <ctype.h>
- #include <errno.h>
- #include <string.hpp>
-
- String &String::remove(int pos, int count)
- {
- if (count <= 0 || pos >= length())
- return *this;
- if (count > length()-pos) count = length()-pos;
- int nl = length()-count;
- srep *p = 0;
- if (nl) {
- p = new(nl) srep(nl);
- if (!p) {
- errno = ENOMEM;
- return *this;
- }
- memmove(p->body,body(),pos);
- memmove(p->body+pos,body()+pos+count,nl-pos);
- }
- if (rp) {
- if (--rp->refs < 1)
- delete rp;
- }
- rp = p;
- rp->refs++;
- return *this;
- }
-